TPT-4285: Implement integration tests for ReservedIP for IPv4#688
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the integration test suite for the SDK's Reserved IPv4 support, covering the new networking APIs plus cross-resource flows where reserved addresses can be tagged or attached to Linodes and NodeBalancers. It fits into the codebase by adding end-to-end coverage around the Reserved IP models and helpers that were recently added to the client, and it is explicitly stacked on top of linked PR #687.
Changes:
- Adds shared integration fixtures for creating reserved IPs and reserved IPs assigned to a Linode.
- Adds networking integration tests for reserved IP create/update/assign/allocate/type-conversion flows.
- Adds cross-resource reserved IP coverage for tags, NodeBalancers, Linode allocation, and interface-based instance creation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
test/integration/conftest.py |
Adds reusable fixtures for creating standalone and assigned Reserved IPv4 addresses. |
test/integration/models/networking/test_networking.py |
Adds the main Reserved IPv4 integration coverage and shared assertion helpers. |
test/integration/models/nodebalancer/test_nodebalancer.py |
Adds NodeBalancer creation coverage using a reserved IPv4 address. |
test/integration/models/linode/test_linode.py |
Adds coverage for attaching an existing reserved IPv4 to a Linode. |
test/integration/models/linode/interfaces/test_interfaces.py |
Adds reserved IPv4 coverage for both legacy and Linode interface-generation instance creates. |
test/integration/models/tag/test_tag.py |
Adds tag retrieval coverage for reserved IPv4 tagged objects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b6cff8d to
4b0f363
Compare
…e#695) Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4 to 5. - [Release notes](https://github.com/actions/dependency-review-action/releases) - [Commits](actions/dependency-review-action@v4...v5) --- updated-dependencies: - dependency-name: actions/dependency-review-action dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
# Conflicts: # conftest.py # linode_api4/groups/networking.py # linode_api4/groups/tag.py # linode_api4/objects/networking.py # test/unit/groups/networking_test.py
4b0f363 to
b9ca4cf
Compare
…lement-integration-tests-for-reserved-ip-for-ipv4
| endpoint = client.base_url + "/networking/reserved/ips/types" | ||
| types = requests.get(endpoint).json()[ | ||
| "data" | ||
| ] # Pricing should be publicly available | ||
|
|
||
| assert isinstance(types, list) | ||
| assert types[0]["id"] == "reserved-ipv4" | ||
| assert types[0]["label"] == "Reserved IPv4" | ||
| assert "hourly" in types[0]["price"] | ||
| assert "monthly" in types[0]["price"] | ||
| assert any(price != 0 for price in list(types[0]["price"].values())) | ||
| assert isinstance(types[0]["region_prices"], list) | ||
|
|
||
|
|
| def create_reserved_ip_assigned(test_linode_client, create_linode): | ||
| client = test_linode_client | ||
| linode = create_linode | ||
| reserved_ip = client.networking.reserved_ip_create( | ||
| region=linode.region, | ||
| tags=["test", "assigned"], | ||
| ) | ||
|
|
||
| client.networking.ip_addresses_assign( | ||
| assignments=[{"address": reserved_ip.address, "linode_id": linode.id}], |
|
|
||
| if region: | ||
| reserved_ip = client.networking.ip_allocate( | ||
| reserved=reserved, region=TEST_REGION | ||
| ) | ||
| verify_reserved_ip(reserved_ip) | ||
| else: | ||
| reserved_ip = client.networking.ip_allocate( | ||
| reserved=reserved, linode=linode.id | ||
| ) | ||
| verify_reserved_ip_assigned(reserved_ip, linode) | ||
|
|
||
| assert reserved_ip.tags == [] | ||
|
|
||
| # clean-up | ||
| reserved_ip = client.load(ReservedIPAddress, reserved_ip.address) | ||
| reserved_ip.delete() |
| nb = client.nodebalancer_create( | ||
| region=reserved_ip.region, | ||
| label=label, | ||
| firewall=e2e_test_firewall.id, | ||
| client_udp_sess_throttle=5, | ||
| ipv4=reserved_ip.address, | ||
| ) |
| ipv4=reserved_ip.address, | ||
| ) | ||
|
|
||
| assert TEST_REGION, nb.region |
| tag, reserved_ip = create_tag_with_reserved_ip | ||
| tag = test_linode_client.load(Tag, tag.id).objects[0] | ||
|
|
||
| assert vars(tag).keys() == vars(reserved_ip).keys() |
| assignments=[{"address": reserved_ip.address, "linode_id": linode.id}], | ||
| region=linode.region, | ||
| ) | ||
|
|
| linode, _ = client.linode.instance_create( | ||
| "g6-nanode-1", | ||
| reserved_ip.region, | ||
| image="linode/debian12", | ||
| label=label, | ||
| interface_generation=iface_type, | ||
| interfaces=[interface], | ||
| ) |
| reserved_ip = create_reserved_ip | ||
| label = get_test_label(length=8) | ||
|
|
||
| if iface_type == InterfaceGeneration.LEGACY_CONFIG: |
There was a problem hiding this comment.
I don't like this "if" based on iface_type. I wonder if you could extract linode_create_with_LEGACY_CONFIG and linode_create_with_standard_interface function. Then put it as parameter here without "if" statement.
The second idea is to just create 2 separate tests.
| request.addfinalizer(reserved_ip.delete) | ||
|
|
||
| verify_reserved_ip(reserved_ip) | ||
| assert reserved_ip.tags == tags if tags else reserved_ip.tags == [] |
There was a problem hiding this comment.
Could you remove that "if" conditional and maybe use 3rd parameter?
| assert reserved_ip.tags == tags if tags else reserved_ip.tags == [] | |
| assert reserved_ip.tags == expected_tags |
| client = test_linode_client | ||
| linode = create_linode | ||
|
|
||
| if region: |
There was a problem hiding this comment.
In my opinion, there would be two tests to make it easier to read and verify results quickly. The second approach would be to put function name as parameter but I'm not sure if it's possible here
📝 Description
Integration tests for Reserved IPs
Required tags:
can_reserve_ipreserved_ips_betareserved_ip_nodebalancer✔️ How to Test
make test-int TEST_ARGS="-k reserved_ip -v"make test-int TEST_ARGS="-k reserve_ephemeral -v"